package de.karlNet.sambamanager.view.beans;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Controller;

import de.karlNet.login.Useraccountcontrol;
import de.karlNet.sambamanager.ldapModel.LdapUser;
import de.karlNet.sambamanager.view.beans.forms.ViewBean;
import de.karlNet.sambamanager.view.beans.trees.LdapTreeBean;

@Controller
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class UserDetailsBean extends ViewBean {
	@Autowired
	private LdapTreeBean ldapTreeBean;

	@Override
	public String getPageName() {
		return "userview";
	}

	public List<Useraccountcontrol> userAccountControlsAsList() {
		List<Useraccountcontrol> ret = new ArrayList<Useraccountcontrol>();
		LdapUser selectedUser = (LdapUser) (this.ldapTreeBean.getSelectedNode()
				.getData());
		for (Useraccountcontrol useraccountcontrol : selectedUser
				.getUseraccountcontrols()) {
			ret.add(useraccountcontrol);
		}
		return ret;
	}
}
